# Maintainer: Thomas Liske <thomas@fiasko-nw.net>
pkgname=bird-lg-go
pkgver=1.3.7.1
pkgrel=1
pkgdesc="BIRD looking glass in Go"
url="https://github.com/xddxdd/bird-lg-go"
arch="all"
license="GPL-3.0-only"
makedepends="go"
options="net"
source="https://github.com/xddxdd/bird-lg-go/archive/v$pkgver/bird-lg-go-$pkgver.tar.gz
	fix-tests.patch

	bird-lg-go.initd
	bird-lgproxy-go.initd
	bird-lg.yaml
	bird-lgproxy.yaml
"
install="
	$pkgname.pre-install
	bird-lgproxy-go.pre-install
"
subpackages="$pkgname-openrc bird-lgproxy-go:lgproxy bird-lgproxy-go-openrc"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make all
}

check() {
	cd $builddir/frontend
	go test -v
}

package() {
	install -Dm755 proxy/proxy "$pkgdir"/usr/bin/bird-lgproxy-go
	install -Dm755 frontend/frontend "$pkgdir"/usr/bin/bird-lg-go

	install -Dm755 "$srcdir/bird-lg-go.initd" "$pkgdir"/etc/init.d/bird-lg-go
	install -Dm644 "$srcdir/bird-lg.yaml" "$pkgdir"/etc/bird-lg/bird-lg.yaml
}

lgproxy() {
	amove usr/bin/bird-lgproxy-go

	install -Dm755 "$srcdir/bird-lgproxy-go.initd" "$pkgdir"/etc/init.d/bird-lgproxy-go
	install -Dm644 "$srcdir/bird-lgproxy.yaml" "$pkgdir"/etc/bird-lg/bird-lgproxy.yaml
}

sha512sums="
47ce85876d217fd8d83b765ee9cde5b50d73a434a0dd485534588df02455918ad9ebcf617981afbb285d0995299997775e1fa74e303fcd960e83bc413d4d9273  bird-lg-go-1.3.7.1.tar.gz
11af420cab348960b587abea5214f2d4933aed6788494c7068e7caeceec2d452440d26c74c468f386958bbe9a989ced0c118b4d8ac09894b9f816f0ed6213669  fix-tests.patch
5547b7a79b854f52f6f57b7955ff9fdabfee4a06801963d4190f39073ead8ae2cf4f113e3a7d1ef1e99bc40a86e873222e20134ce15c53776419a3fb11dd7620  bird-lg-go.initd
f8b897fd3b05b8644002ff9570cd03978221cf6663b9be1b66b71eff3eb8e750b235cd6e57f3c4bade7f07e1d28ae2a5702e7ce508821bbc9a87af79b1c14b99  bird-lgproxy-go.initd
e6d38b8cc0b8b53a49fef59508bea40a6b81c8734cb44ab6cb69af89c76554f4ef538039b1767b88cd5922881de7c565e7153da57585290951f577e9ebcf068c  bird-lg.yaml
f53118b333efb8bb4aa12fbdf68a1ac534bc779c921fa0ee0b701ff5ff7d28aba169e19df943cd29f517d4e840c5429dd98d2ef378286a1ba96359c76a48740a  bird-lgproxy.yaml
"
